<?php
session_start();
include 'common/check.php';
include '../business/user_manager.php';
include_once '../entity/user_entity.php';

$userMng = new UserMng();
$userEntity = new UserEntity();

$userEntity->id         = $_SESSION['userID'];
$userEntity->email      = $_POST['txt_email'];
$userEntity->firstName  = $_POST['txt_firstName'];
$userEntity->lastName   = $_POST['txt_lastName'];
$userEntity->passwd     = md5($_POST['txt_passwd']);

if ($userMng->update($userEntity)) {
    $SESSION['email'] = $userEntity->email;
    $SESSION['name'] = $userEntity->firstName . " " . $userEntity->lastName;
    echo "<script>window.location.href='dashboard.php';</script>";
} else {
    die("Update failed.");
}


?>
